<template>
  <div :class="`vip-chat${otherClass}`" :title="data['time']">
    <div class="image">
      <img alt="Avatar" :src="data['avatar']" class="avatar"/>
      <div class="mask"/>
    </div>
    <span class="name" :style="`color: ${data['nameColor']}`">{{ data['username'] }}</span>
    <div style="flex: 1"></div>
    <span v-for="item in data['identities']" :class="`identity identity_${item}`"></span>
    <span class="gift">{{ translate('开通') + data['gift'] }}</span>
    <span :class="`gift_${data['giftId']}`"></span>
    <div class="mask"></div>
  </div>
</template>

<script setup>
import {computed, inject} from 'vue'

const props = defineProps({
  data: {
    type: Object,
    default: {}
  }
})
const config = inject('config')
const translate = inject('translate')
const otherClass = computed(() => {
  let result = ''
  for (let identity of props.data['identities'])
    result += ' vip-chat_' + identity
  return result
})
const msg = computed(() => {
  let result = props.data['content']
  for(let item of config.shield.Keyword) {
    let length = item.length
    let stars = ''
    for (let i = 0; i < length; i++) stars += '*'
    result = result.replace(item, stars)
  }
  return result
})
</script>

<style scoped lang="scss">
.vip-chat {
  width: calc(100% - 2rem);
  position: relative;
  display: flex;
  align-items: center;
  padding: 2rem;
  margin: .4rem 1rem;
  background: var(--z-active-color);
  color: var(--z-light-color);
  font-weight: bold;

  * {
    flex-shrink: 0;
  }

  .image {
    position: relative;
    width: 3.2rem;
    height: 3.2rem;
    margin-right: .8rem;

    .avatar {
      width: 100%;
      height: 100%;
      border-radius: 50%;
    }

    .mask {
      position: absolute;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
    }
  }

  .name {
    margin: 0 .4rem;
    font-size: 1.2rem;
  }

  .gift {
    font-size: 1.6rem;
  }

  .mask {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
  }
}
</style>